import http from '~/plugins/HTTP';

const API = {
  POST_NEW_ARTICLE: '/api/v1/article', // 发布、删除新文章
  POST_CREATE_TAG: '/api/v1/category', // 创建标签、分类
  POST_UPDATE_WORD: '/api/v1/article/update', // 更新文章
  DELETE_WORD_TAG: '/api/v1/category/', // {id} 删除标、分类
  GET_WORD_TAGS: '/api/v1/category/list', // 获取标签、分类
  GET_WORD_DETAIL: '/api/v1/article/', // 获取文章详情
  GET_WORD_LIST: '/api/v1/article/list', // 获取文章列表
  POST_LIKE_WORD: '/api/v1/default/like', // 给文章或者评论点赞
  POST_DISABLE_WORD: '/api/v1/article/disable', // 禁用文章
};

export default {
  postNewArticle(data) {
    return http.post(API.POST_NEW_ARTICLE, data)
  },
  deleteThisWord(data) {
    return http.delete(API.POST_NEW_ARTICLE, { data })
  },
  postCreateTag(data) {
    return http.post(API.POST_CREATE_TAG, data)
  },
  postUpdateWord(data) {
    return http.post(API.POST_UPDATE_WORD, data)
  },
  deleteWordTag(id) {
    return http.delete(API.DELETE_WORD_TAG + id)
  },
  getWordTags(params) {
    return http.get(API.GET_WORD_TAGS, { params })
  },
  getWordDetail(wordID, params) {
    return http.get(API.GET_WORD_DETAIL + wordID + '/detail', { params })
  },
  getWordList(params) {
    return http.get(API.GET_WORD_LIST, { params })
  },
  postLikeWord(data) {
    return http.post(API.POST_LIKE_WORD, data)
  },
  postDisableWord(data) {
    return http.post(API.POST_DISABLE_WORD, data)
  }
}